/*
	jGrouse framework
	Copyright 2007 by Denis Riabtchik 
	All rights reserved.
	
	Licensed under modified BSD license. See license.txt for details
*/

/**
 * Contains base class for jGrouse objects
 * @module jgrouse.base
 */

jgrouse.module(
{
	name: 'jgrouse.base',
	body : function(embed)
	{
		eval(embed);

	/**
		Base class for jGrouse objects.
		Defines methods to compare for equality, code and object identity.
		@class jgrouse.BaseObject
	*/
	jgrouse.define('jgrouse.BaseObject', null, function(salt)
	{
		eval(salt);
		
		var current = 0;
		
		function nextId()
		{
			var res = current++;
			if (current == Number.MAX_VALUE)
			{
				current = Number.MIN_VALUE;
			}
			return res;
		}
		
		return 	{
			/**
				Unique identifier of the object's instance
				@variable __serialObjectId 
			*/
			/**
				Initializes new instance of object. Sets unique object id.
				@constructor initialize
			*/
			initialize : function()
			{
				this.__serialObjId = nextId();
			},
			
			/**
				simple equal method based on object's identity
				@function equals
				@param {object} obj object to be compared
				@returns true if obj is the same object as this
			*/
			equals : function(obj)
			{
				return this === obj;
			},
			
			/**
				simple hashCode method based on object identity
				@function hashCode
				@returns {int} serial object id
			*/
			hashCode : function()
			{
				return this.__serialObjId;
			}
		};
		
	})


		
	}
})
